# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: jaewon

from experimental.prophet.graph import graph
from experimental.prophet.graph.shape import Shape
from experimental.prophet.ops.placeholder import placeholder


def global_timestamp():
  try:
    return graph.get_named_variable('global_timestamp')
  except KeyError:
    pass

  ts_var = placeholder(node_name='global_timestamp', dtype=int, shape=Shape.Scalar(), namespace='')
  return ts_var.named_ref('global_timestamp', namespace='')
